/*
 * @Author: long-xinyu2 2192763423@qq.com
 * @Date: 2025-04-01 10:09:57
 * @LastEditors: long-xinyu2 2192763423@qq.com
 * @LastEditTime: 2025-05-12 11:06:29
 * @FilePath: \algorithm\algorithm-training\lqb\acwing4_1.cpp
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#include<iostream>
#include<cstring>
#include<vector>
#include<map>
#include<cstdio>
#include<algorithm>
#include<string>
#include<string.h>
#include<queue>
#include<math.h>
#include<set>
#include<functional>
#include <bitset>
using namespace std;
using ull = unsigned long long;
using i128 = __int128_t;
//inline int inc(int x,int v,int mod){x+=v;return x>=mod?x-mod:x;}//代替取模+
#define endl '\n'
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
#define int long long

const int N = 1e5+10;

void solve()
{
    int n;
    cin >> n;
    cout << 1 << endl;
    vector<int>arr(n + 10);
    int sum = 0;
    for(int i = 1; i <= n; i ++) 
    {
        cin >> arr[i];
        sum += arr[i];
    }
    vector<PII> ans(sum, + 10);
    int cnt = 1;
    queue<int>q;
    q.push(1);
    for(int i = 2;  i <= n ; i ++)
    {
        int nowx = arr[i];
        while(q.size())
        {
            auto t = q.front();
            q.pop();
            if(nowx > 2)
            {
                ans[nowx] = {cnt + 1,cnt + 2};
                q.push(cnt + 1);
                q.push(cnt + 2);
                cnt += 2;

            }
            else
            {
                if(nowx == 2)
                {
                    ans[nowx] = {cnt + 1,cnt + 2};
                    cnt += 2;
                    q.push(cnt + 1);
                    q.push(cnt + 2);
                }
                else 
                {
                    ans[nowx] = {cnt + 1,-1};
                    cnt += 1;
                    q.push(cnt + 1);
                }
                break;
            }
        }
    }
    for(int i = 1; i <= sum; i ++)
    {
        if(ans[i].second == 0) ans[i].second = -1;
        if(ans[i].first == 0) ans[i].first = -1;
    }
    for(int i = 1; i <= sum; i ++)
    {
        cout << ans[i].first << " " << ans[i].second << endl;
    }
}
signed main()
{
    int t = 1;
    //cin >> t;
    while(t --)
    {
        solve();
    }
}
